package com.duan.common.utils;


import com.duan.common.beans.vo.ResponseVO;
import com.duan.common.enums.ResponseENUM;

/**
 * Created by duanlsh on 18/6/14.
 */
public abstract class ResponseUtil {

    public static <T> ResponseVO<T> success() {
        return success(null);
    }

    public static <T> ResponseVO<T> success(T t) {
        return success(ResponseENUM.SUCCESS.getCode(), ResponseENUM.SUCCESS.getMessage(), t);
    }

    public static <T> ResponseVO<T> success(String message, T t) {
        return new ResponseVO<T>(ResponseENUM.SUCCESS.getCode(), message, t);
    }

    public static <T> ResponseVO<T> success(int code, String message, T t) {
        return new ResponseVO<T>(code, message, t);
    }

    public static <T> ResponseVO<T> fail() {
        return fail(ResponseENUM.FAIL.getCode());
    }

    public static <T> ResponseVO<T> fail(int code) {
        return fail(code, ResponseENUM.FAIL.getMessage());
    }

    public static <T> ResponseVO<T> fail(String message) {
        return fail(ResponseENUM.FAIL.getCode(), message);
    }

    public static <T> ResponseVO<T> fail(int code, String message) {
        return fail(code, message, null);
    }

    public static <T> ResponseVO<T> fail(int code, String message, T t) {
        return new ResponseVO<T>(code, message, t);
    }
}
